feat(deno): add openai integration#22467
Conversation
9ea3b80 to
247a3be
Compare
4a7b537 to
4fa1a42
Compare
247a3be to
166b082
Compare
4fa1a42 to
932c59a
Compare
166b082 to
1b4d06d
Compare
932c59a to
2c24656
Compare
| Deno.test('openai instrumentation: orchestrion:openai:chat channel produces a nested gen_ai span', async () => { | ||
| resetGlobals(); | ||
| const sink = transactionSink(); | ||
| init({ |
There was a problem hiding this comment.
Bug: The global installedIntegrations array is not reset between tests, causing setupOnce() to be skipped in the second test, which prevents channel subscribers from being registered and leads to test failure.
Severity: MEDIUM
Suggested Fix
The global state needs to be reset between test runs. The installedIntegrations array should be cleared as part of the test teardown or setup process. For example, the resetGlobals() function could be modified to also clear this array, ensuring each test runs in an isolated environment and setupOnce() is called correctly.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: dev-packages/deno-integration-tests/suites/orchestrion-openai/test.ts#L68-L71
Potential issue: The integration test suite contains two separate tests that both call
`init()`. The first test populates the global `installedIntegrations` array. Because
this array is not reset between tests, the second test's call to `init()` finds the
integration is already present in the list. This prevents the `setupOnce()` function
from running during the second test. As `setupOnce()` is responsible for registering
subscribers to the `orchestrion:openai:chat` channel, no subscribers are registered for
the second test. Consequently, when the test publishes events to this channel, there are
no listeners, causing the test to fail its assertions for created spans.
Also affects:
dev-packages/deno-integration-tests/suites/orchestrion-openai/test.ts:57~62
Did we get this right? 👍 / 👎 to inform future reviews.
1b4d06d to
6fd91f7
Compare
2c24656 to
1f07c42
Compare
6fd91f7 to
c6b3064
Compare
1f07c42 to
7afd3e8
Compare
7afd3e8 to
9e6a9cd
Compare
c6b3064 to
fb817bc
Compare
| dsn: 'https://username@domain/123', | ||
| tracesSampleRate: 1, | ||
| beforeSendTransaction: sink.beforeSendTransaction, | ||
| }); |
There was a problem hiding this comment.
Bug: The global installedIntegrations array is not reset between tests, causing setupOnce() to be skipped on subsequent init() calls and breaking integration functionality.
Severity: MEDIUM
Suggested Fix
Reset the installedIntegrations array between tests. This can be achieved by adding installedIntegrations.length = 0 to the resetGlobals() function or another appropriate test teardown hook to ensure each test starts with a clean state.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: dev-packages/deno-integration-tests/suites/orchestrion-openai/test.ts#L68-L71
Potential issue: The global `installedIntegrations` array is not reset between tests.
When `init()` is called a second time in the test suite, `setupIntegration()` finds the
integration name already present in the array and skips the `setupOnce()` call. This
prevents necessary channel listeners from being established for the second test run.
Consequently, expected spans are not created, leading to test failures, such as an
assertion for an `aiSpan` failing because the `gen_ai.chat` span was never generated.
size-limit report 📦
|
No description provided.